<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猪八戒</title>
    <style>
        .my-container {
            border: 1px solid blue;
            width: 400px;
            height: 500px;
            margin: 0 auto;
            position: relative;
            top: 0px;
            background-image: url('images/pig.png');
            background-size: cover;
        }
        
        .yes-btn {
            border: none;
            font-size: 14px;
            background: #FC5531;
            border-radius: 50px;
            padding: 5px 20px;
            color: #FFFFFF;
            position: absolute;
            bottom: 0px;
            left: 0px;
            cursor: pointer;
        }
        
        .no-btn {
            border: none;
            font-size: 14px;
            background: #FC5531;
            border-radius: 50px;
            padding: 5px 20px;
            color: #FFFFFF;
            position: absolute;
            bottom: 0px;
            right: 0px;
            cursor: pointer;
        }
        
        .yes-btn:hover {
            background: #FC1944;
        }
        
        .no-btn:hover {
            background: #FC1944;
        }
        
        .close-img {
            font-size: 16px;
            color: blue;
            font-weight: bold;
            width: 100px;
            position: absolute;
            top: 0px;
            left: 300px;
            cursor: pointer;
        }
        
        .close-img-hover {
            position: relative;
            top: 100px;
            left: 100px;
            cursor: pointer;
        }
        
        .my-content {
            background-image: url('images/pig.png');
            background-size: cover;
            width: 400px;
            height: 500px;
        }
    </style>
</head>

<body>

    <div class="my-container">
        <span id="img_close_id" class="close-img" onmouseover="imgOver()">算了，不吃了</span>
        <button id="yes_pig_id" class="yes-btn" onclick="pigClick()" onmouseover="wantOver()" onmouseout="wantOut()"> 
            好想吃
        </button>
        <button id="no_pig_id" class="no-btn" onmouseover="pigMouseOver()" onmouseout="pigMouseOut()" onclick="pigClick()">
            不，我不想
        </button>
    </div>

    <script>
        function pigClick() {
            alert("我是小居居^_^");
        }

        function wantOver() {
            var obj = document.getElementById("yes_pig_id");
            obj.innerHTML = "吃不到...";
        }

        function wantOut() {
            var obj = document.getElementById("yes_pig_id");
            obj.innerHTML = "好想吃";
        }

        function pigMouseOver() {
            var obj = document.getElementById("no_pig_id");
            obj.innerHTML = "想吃，内心好挣扎...";
        }

        function pigMouseOut() {
            var obj = document.getElementById("no_pig_id");
            obj.innerHTML = "我不想";
        }

        function imgOver() {
            var obj = document.getElementById("img_close_id");
            var top = Math.ceil(Math.random() * 200);
            var left = Math.ceil(Math.random() * 200);
            obj.setAttribute("style", "course:pointer; position:relative;top:" + top + "px" + ";" + "left:" + left + "px");

        }
    </script>

</body>

</html>